import React from 'react';
import { Select, Input } from 'antd';
import ConfigTable from '../../../../components/configTable';
import { TYPE_OPTIONS } from '../../../../../../utils/constant';

const ReturnResult = (props) => {
  const { value, onChangeReturningMaps, onChangeRetuningMapsList } = props;

  const defaultData = {
    innerPath: '',
    type: 0,
    isReturning: 1,
  };

  const cusColumns = [
    {
      title: '出参名',
      dataIndex: 'innerPath',
      render: (text, _, index) => (
        <Input
          value={text}
          maxLength={50}
          placeholder='请输入'
          onChange={(e) => onChangeReturningMaps(e.target.value, index, 'innerPath')}
        />
      ),
    },
    {
      title: '类型',
      dataIndex: 'type',
      render: (text, _, index) => (
        <Select placeholder='请选择' value={text} onChange={(value) => onChangeReturningMaps(value, index, 'type')}>
          {TYPE_OPTIONS.map((item, index) => (
            <Select.Option value={index} key={index}>
              {item}
            </Select.Option>
          ))}
        </Select>
      ),
    },
  ];

  return (
    <ConfigTable
      data={value.returningMaps}
      onChange={onChangeRetuningMapsList}
      cusColumns={cusColumns}
      defaultData={defaultData}
    />
  );
};
export default ReturnResult;
